import os
try:
    import xml.etree.cElementTree as ET
except ImportError:
    import xml.etree.ElementTree as ET
import cv2
video_file =  '/home/sean/data/ILSVRC/ImageSets/VID/train_video_remove_no_object.txt'
anno_path = '/home/sean/data/MOT/2DMOT2015/train/KITTI-13/gt'
img_path = '/home/sean/data/MOT/2DMOT2015/train/KITTI-13/img1'
#kitti13_skip = [1~5,134~207]

# print(anno_in_video_path)

ordered_file_num = list(range(6, 134))+list(range(208, 341))
print(len(ordered_file_num))
new_ordered_file_num = list(range(1,len(ordered_file_num)+1))
print(len(new_ordered_file_num))


for old_num, new_num in zip(ordered_file_num, new_ordered_file_num):
    if old_num != new_num:
        old_xml_name = os.path.join(anno_path, 'gt_'+str(old_num).zfill(6)+'.txt')
        new_xml_name = os.path.join(anno_path, 'gt_'+str(new_num).zfill(6)+'.txt')
        old_img_name = os.path.join(img_path, str(old_num).zfill(6) + '.jpg')
        new_img_name = os.path.join(img_path, str(new_num).zfill(6) + '.jpg')
        os.rename(old_xml_name, new_xml_name)
        os.rename(old_img_name, new_img_name)
        print(old_img_name, new_img_name)
        print(old_xml_name, new_xml_name)
